﻿using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using OpenAiClient.Models;
using OpenAiClient.Repositories;
using OpenAiClient.Services;
using OpenAiClient.ViewModels;
using Prism.Events;

namespace OpenAiClient.Views
{
    /// <summary>
    /// HistoryView.xaml 的交互逻辑
    /// </summary>
    // ReSharper disable once RedundantExtendsListEntry
    public partial class HistoryView : UserControl
    {
        private readonly HistoryViewModel _viewModel;

        public HistoryView(
            ILogService logService,
            IRepository<HistoryModel> historyRepository,
            IEventAggregator eventAggregator
        )
        {
            InitializeComponent();

            _viewModel = new HistoryViewModel(
                logService,
                historyRepository,
                eventAggregator
            );

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                DataContext = _viewModel;
            }
        }

        private async void HistoryView_OnLoadedAsync(object sender, RoutedEventArgs e)
        {
            await _viewModel.ResetAsync();
        }
    }
}
